package cn.study.vue_project_xxx.manager;


import cn.study.vue_project_xxx.entity.po.Menu;
import cn.study.vue_project_xxx.mapper.MenuMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class MenuManager {

    @Resource
    MenuMapper menuMapper;

    /*
    * 查询出所有一级类目
    * */
    public List<Menu> selectFirstLevelDirectory() {
        LambdaQueryWrapper<Menu> menuLambdaQueryWrapper = new LambdaQueryWrapper<>();
        menuLambdaQueryWrapper.eq(Menu::getMenuFatherId,null);
        return menuMapper.selectList(menuLambdaQueryWrapper);
    }

    /*
    * 查询出所有该级的子级目录
    * */
    public List<Menu> selectChildDirectory(Menu menu) {
        Integer id = menu.getId();
        LambdaQueryWrapper<Menu> menuLambdaQueryWrapper = new LambdaQueryWrapper<>();
        menuLambdaQueryWrapper.eq(Menu::getMenuFatherId,id);
        return menuMapper.selectList(menuLambdaQueryWrapper);
    }
}
